<template>
  <div>
    <div class="item" v-for="(item,index) of list" :key="index">
      <div class="item-title border-bottom">
        <span class="item-title-icon"></span>
        {{item.title}}
      </div>
      <div v-if="item.children" class="item-children">
        <!--
          这里使用到了递归组件
          先去判断item里面有没有children这个数组。
          有的话就遍历，没有就不遍历
          然后再将item.children传到组件本身即可
         -->
        <DetailList :list="item.children"></DetailList>
      </div>
    </div>
  </div>
</template>

<script>
  export default {
    name: 'DetailList',
    props: {
      list: Array
    }
  }
</script>

<style lang="less" scoped>
  .item-title{
    line-height: .8rem;
    font-size: .32rem;
    padding: 0 .2rem;
    .item-title-icon{
      position: relative;
      left: .06rem;
      top: .06rem;
      display: inline-block;
      width: .36rem;
      height: .36rem;
      background: url(//s.qunarzz.com/piao/image/touch/sight/detail.png) 0 -.45rem no-repeat;
      margin-right: .1rem;
      background-size: .4rem 3rem;
    }
  }
  .item-children{
    padding: 0 .2rem;
  }
</style>
